package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MoneyPercentage;
import com.ruoyi.system.service.IMoneyPercentageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 提现费率Controller
 *
 * @author ruoyi
 * @date 2021-03-09
 */
@RestController
@RequestMapping("/system/percentage")
public class MoneyPercentageController extends BaseController
{
    @Autowired
    private IMoneyPercentageService moneyPercentageService;

    /**
     * 查询提现费率列表
     */
    @PreAuthorize("@ss.hasPermi('system:percentage:list')")
    @GetMapping("/list")
    public TableDataInfo list(MoneyPercentage moneyPercentage)
    {
        startPage();
        List<MoneyPercentage> list = moneyPercentageService.selectMoneyPercentageList(moneyPercentage);
        return getDataTable(list);
    }

    /**
     * 导出提现费率列表
     */
    @PreAuthorize("@ss.hasPermi('system:percentage:export')")
    @Log(title = "提现费率", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MoneyPercentage moneyPercentage)
    {
        List<MoneyPercentage> list = moneyPercentageService.selectMoneyPercentageList(moneyPercentage);
        ExcelUtil<MoneyPercentage> util = new ExcelUtil<MoneyPercentage>(MoneyPercentage.class);
        return util.exportExcel(list, "percentage");
    }

    /**
     * 获取提现费率详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:percentage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(moneyPercentageService.selectMoneyPercentageById(id));
    }

    /**
     * 新增提现费率
     */
    @PreAuthorize("@ss.hasPermi('system:percentage:add')")
    @Log(title = "提现费率", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MoneyPercentage moneyPercentage)
    {
        return toAjax(moneyPercentageService.insertMoneyPercentage(moneyPercentage));
    }

    /**
     * 修改提现费率
     */
    @PreAuthorize("@ss.hasPermi('system:percentage:edit')")
    @Log(title = "提现费率", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MoneyPercentage moneyPercentage)
    {
        return toAjax(moneyPercentageService.updateMoneyPercentage(moneyPercentage));
    }

    /**
     * 删除提现费率
     */
    @PreAuthorize("@ss.hasPermi('system:percentage:remove')")
    @Log(title = "提现费率", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(moneyPercentageService.deleteMoneyPercentageByIds(ids));
    }
}
